//
// Created by 吴楷泓 on 2121/12/17.
//
#include <stdio.h>
#include <stdlib.h>

struct Student {
    int xh;
    char name[20];
    int score;
    int rank;
};

void Compute(struct Student students[], int numberOfStudent) {
    int i, j;
    for(i = 1; i <= numberOfStudent; i++) {
        students[i].rank = 1;
        int score = students[i].score;
        for(j = 1; j <= numberOfStudent; j++) {
            if(students[j].score > score) {
                students[i].rank++;
            }
        }
    }
}

int compareFunction(const void *student1, const void* student2) {
    return (*(struct Student*)student2).score - (*(struct Student*)student1).score;
}

void swap(struct Student* stu1, struct Student * stu2) {
    struct Student t = *stu1;
    *stu1 = *stu2;
    *stu2 = t;
}

void quickSort(int l, int r, struct Student students[]) {
    if(l >= r) return;
    int i = l - 1, j = r + 1;
    int x = students[l + r >> 1].score;
    while(i < j) {
        do ++i; while(students[i].score > x);
        do --j; while(students[j].score < x);
        if(i < j) swap(&students[i], &students[j]);
    }
    quickSort(l, j, students);
    quickSort(j + 1, j, students);
}

void bubbleSort(struct Student students[], int numberOfStudent) {
    int bound, exchange = numberOfStudent, i;
    while(exchange) {
        bound = exchange, exchange = 0;
        for(i = 1; i < bound; i++) {
            if(students[i].score < students[i + 1].score) {
                swap(&students[i], &students[i + 1]);
                exchange = i;
            }
        }
    }
}

int main() {
    struct Student students[11];
    int numberOfStudent;
    scanf("%d", &numberOfStudent);
    int i;
    for(i = 1; i <= numberOfStudent; i++) {
        scanf("%d", &students[i].xh);
        scanf("%s", students[i].name);
        scanf("%d", &students[i].score);
    }

    Compute(students, numberOfStudent);
    bubbleSort(students, numberOfStudent);
    for(i = 1; i <= numberOfStudent; i++) {
        printf("%d %s %d %d\n", students[i].xh, students[i].name, students[i].score, students[i].rank);
    }

    return 1;
}

